const express = require("express");

const app = express();

app.get("/", (req, res, next) => {
  // 手动制造一个异常
  let error = new Error("Something wrong");
  error.status = 404;
  // 传递给下一个中间件
  next(error);
});

app.use((err, req, res, next) => {
  if (err.status) {
    res.status(err.status || 500).send("Error");
  } else next();
});



app.listen(3000,()=>{
    console.log("3000");
})